<template>
  <div class="goods_list">
        <div class="cartgoods">
          <img src="../assets/images/cartgoods.png" alt="">
        </div>
        <section class="goods">
            <div v-for="item in list" :key="item.id">
                <router-link 
                :to="{path:'/detail',
                query:{ //params
                        id:item.id,
                    }}">
                    <img :src="item.url" alt="">
                    <p>{{item.title}}</p>
                    <p>
                        &yen; <span>{{item.price}}</span> 起        
                    </p>
                </router-link>
            </div>
        </section>
      </div>
</template>

<script>
import axios from 'axios';
export default {
    name:'regoods',
    data() {
    return {
      list:[]
    }
  },
  
  mounted() {
    axios.get(`http://localhost:3000/xiaomi?type=手机`).then(
            response => {
                this.list = response.data.list
            },
            error =>{
                console.log('失败');
            }
        )
  },
}
</script>

<style scoped>
    .goods_list .cartgoods img {
      width: 100%;
    }

section.goods {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
}

section.goods div a {
    display: flex;
    width: 7.2rem;
    margin: 0.4rem 0;
    flex-direction: column;
    align-items: center;
    color: #999;
    background: #fff;
}

section.goods img {
    width: 100%;
}

section.goods p {
    width: 85%;
    line-height: 1.5em;
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
}

section.goods a p:first-of-type {
    font-size: 0.56rem;
    color: #333;
    margin-top: 0.4rem;
}

section.goods a p:nth-of-type(2) {
    font-size: 0.48rem;
}

section.goods a p:last-of-type {
    font-size: 0.52rem;
    color: #e2625b;
}

section.goods a p:last-of-type span {
    font-size: 0.56rem;
}
</style>